package org.zjz
import java.io.{File, FileInputStream}
import java.util.Objects

import org.apache.poi.xwpf.usermodel.{XWPFDocument, XWPFParagraph}

import scala.collection.JavaConverters.asScalaBuffer
import com.google.common.base.Preconditions._
import org.apache.poi.ooxml.POIXMLDocument

import scala.collection.mutable
import scala.util.matching.Regex
object BatUtils {
  implicit def javaListToScalaList[T](list:java.util.List[T]): mutable.Buffer[T] ={
      asScalaBuffer(list)
  }
  def fileType(path:String,list: Array[String])(implicit regex:Regex=new Regex("(?<=\\.)[^}]*")):(String,Boolean)={
    val matchedChart=regex findFirstIn path
    var hasChart=false
    if(Objects.isNull(matchedChart.getOrElse(null))) return (null,hasChart)
    if (list.contains(matchedChart.get)){
      hasChart=true
    }
    (matchedChart.getOrElse(null),hasChart)
  }
}
